/**
 * 
 */
package com.tbdgroup.babycare.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * @author wsf
 * 
 */
public class DBHelper extends SQLiteOpenHelper {

	private static final String DB_NAME = "babycare.db";

	private static final int DB_VERSION = 4;

	public static final String EVENT_TABLE = "event";

	public DBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite
	 * .SQLiteDatabase)
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS "
				+ EVENT_TABLE
				+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, type VARCHAR, start INTEGER, end INTEGER)");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite
	 * .SQLiteDatabase, int, int)
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE " + EVENT_TABLE);
		db.execSQL("CREATE TABLE IF NOT EXISTS "
				+ EVENT_TABLE
				+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, type VARCHAR, start VARCHAR, end VARCHAR)");
	}

}
